package com.f5.management.controller;

import com.f5.management.entity.Member;
import com.f5.management.entity.Toll;
import com.f5.management.entity.TollDetail;
import com.f5.management.service.TollDetailService;
import com.f5.management.utils.PageResult;
import com.f5.management.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/tollDetail")
@CrossOrigin(origins = {"http://localhost:8080", "null"})
public class TollDetailController {
    @Autowired
    TollDetailService tollDetailService;

    @RequestMapping("/findByPage")
    public PageResult<List<TollDetail>> findByPage(int page, int size) {

        System.out.println(tollDetailService.findByPage(page, size));

        return tollDetailService.findByPage(page, size);
    }
    @RequestMapping("/add")
    public ResponseResult<String> add(TollDetail tollDetail) {

        return new ResponseResult<String>(tollDetailService.add(tollDetail));
    }
    @RequestMapping("/findCidByName")
    public int findCidByName(String communityName){
//        System.out.println(tollDetailService.findCidByName(communityName));
        return tollDetailService.findCidByName(communityName);
    }
    @RequestMapping("/findMember")
    public List<Member> findMemberByName(){
        System.out.println(tollDetailService.findMemberByName());
        return tollDetailService.findMemberByName();
    }
    @RequestMapping("/findById")
    public  TollDetail findById(int id){

        return tollDetailService.findById(id);
    }
    @RequestMapping("/updateInfo")
    public ResponseResult<String> updateInfo(TollDetail tollDetail) {

        return new ResponseResult<String>(tollDetailService.updateInfo(tollDetail));

    }
    @RequestMapping("/delInfo")
    public ResponseResult<String> delInfo(int id) {

        return new ResponseResult<String>(tollDetailService.delInfo(id));

    }



}
